*/
$wgDBmwschema = null;
+/**
+ * Default group to use when getting database connections.
+ */
+$wgDBDefaultGroup = null;
+
/**
* To override default SQLite data directory ($docroot/../data)
*/
'cliMode' => $wgCommandLineMode,
'hostname' => wfHostname(),
'readOnlyReason' => $readOnlyMode->getReason(),
+ 'defaultGroup' => $mainConfig->get( 'DBDefaultGroup' ),
];
// When making changes here, remember to also specify MediaWiki-specific options
/** @var string One of the ROUND_* class constants */
private $trxRoundStage = self::ROUND_CURSORY;
+ /** @var string|null */
+ private $defaultGroup = null;
+
const ROUND_CURSORY = 'cursory';
const ROUND_BEGINNING = 'within-begin';
const ROUND_COMMITTING = 'within-commit';
$this->cliMode = $conf['cliMode'] ?? ( PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' );
$this->hostname = $conf['hostname'] ?? gethostname();
$this->agent = $conf['agent'] ?? '';
+ $this->defaultGroup = $conf['defaultGroup'] ?? null;
$this->ticket = mt_rand();
}
'hostname' => $this->hostname,
'cliMode' => $this->cliMode,
'agent' => $this->agent,
+ 'defaultGroup' => $this->defaultGroup,
'chronologyCallback' => function ( ILoadBalancer $lb ) {
// Defer ChronologyProtector construction in case setRequestInfo() ends up
// being called later (but before the first connection attempt) (T192611)
/** @var string Stage of the current transaction round in the transaction round life-cycle */
private $trxRoundStage = self::ROUND_CURSORY;
+ /** @var string|null */
+ private $defaultGroup = null;
+
/** @var int Warn when this many connection are held */
const CONN_HELD_WARN_THRESHOLD = 10;
$this->trxRoundStage = self::ROUND_ROLLBACK_CALLBACKS;
}
}
+
+ $this->defaultGroup = $params['defaultGroup'] ?? null;
}
/**
}
}
+ // Check one "group" per default: the generic pool
+ $defaultGroups = $this->defaultGroup ? [ $this->defaultGroup ] : [ false ];
+
$groups = ( $groups === false || $groups === [] )
- ? [ false ] // check one "group": the generic pool
+ ? $defaultGroups
: (array)$groups;
$masterOnly = ( $i == self::DB_MASTER || $i == $this->getWriterIndex() );
if ( $this->getDbType() > 0 ) {
$this->addOption( 'dbuser', 'The DB user to use for this script', false, true );
$this->addOption( 'dbpass', 'The password to use for this script', false, true );
+ $this->addOption( 'dbgroupdefault', 'The default DB group to use.', false, true );
}
# Save additional script dependant options to display
*/
public function finalSetup() {
global $wgCommandLineMode, $wgShowSQLErrors, $wgServer;
- global $wgDBadminuser, $wgDBadminpassword;
+ global $wgDBadminuser, $wgDBadminpassword, $wgDBDefaultGroup;
global $wgDBuser, $wgDBpassword, $wgDBservers, $wgLBFactoryConf;
# Turn off output buffering again, it might have been turned on in the settings files
if ( $this->mDbPass ) {
$wgDBadminpassword = $this->mDbPass;
}
+ if ( $this->hasOption( 'dbgroupdefault' ) ) {
+ $wgDBDefaultGroup = $this->getOption( 'dbgroupdefault', null );
+ }
if ( $this->getDbType() == self::DB_ADMIN && isset( $wgDBadminuser ) ) {
$wgDBuser = $wgDBadminuser;